﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserList.aspx.cs" Inherits="CPPEI.Coolzon.ManagementCenter.UserList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用户列表</title>
   <link rel="stylesheet" type="text/css" href="Themes/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="Themes/icon.css"/>
    <link rel="stylesheet" type="text/css" href="Themes/demo.css"/>
    <script type="text/javascript" src="Script/jquery.min.js"></script>
    <script type="text/javascript" src="Script/jquery.easyui.min.js"></script>
      <style type="text/css">
        #fm{
            margin:0;
            padding:10px 30px;
        }
        .ftitle{
            font-size:14px;
            font-weight:bold;
            padding:5px 0;
            margin-bottom:10px;
            border-bottom:1px solid #ccc;
        }
        .fitem{
            margin-bottom:5px;
        }
        .fitem label{
            display:inline-block;
            width:80px;
        }
    </style>
</head>
    
<body>
    <form id="form1" runat="server">

             
   
    <div style="position: absolute; left: 20%">
        <asp:Button ID="_ctlAddUser" runat="server" Text="添加" OnClick="_ctlAddUser_Click" />
        <asp:GridView ID="gvUserList" runat="server" AutoGenerateColumns="False" OnRowEditing="gvUserList_RowEditing" Width="100%" OnRowDeleting="gvUserList_RowDeleting" OnRowUpdating="gvUserList_RowPrivileges" >
            <Columns>
                <asp:TemplateField HeaderText="Id" Visible="False">
                    <ItemTemplate>
                        <asp:Label ID="lblId" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Id") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="用户名">
                    <ItemTemplate>
          <%# DataBinder.Eval(Container.DataItem, "Account") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="姓名">
                    <ItemTemplate>
          <%# DataBinder.Eval(Container.DataItem, "Name") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="创建时间">
                    <ItemTemplate>
          <%# DataBinder.Eval(Container.DataItem, "CreateDate") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="操作">
                 <ItemTemplate>
                   <asp:LinkButton ID="LinkButton0" runat="server" CausesValidation="False" CommandName="Update"
                                                            Text="权限"></asp:LinkButton>
                   <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                                            Text="编辑"  ></asp:LinkButton>
                    <%-- <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:EditUser()">编辑</a>--%>
                   <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Delete"
                                                            Text="删除" OnClientClick ="return confirm('你确定要删除吗？')"></asp:LinkButton>
                  </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView> 
         <div id="w" class="easyui-window"  data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:500px;height:300px;padding:10px;">
         <iframe id="mainframe"  frameborder="no" width="100%" height="100%" scrolling="no" ></iframe>
    </div>
    </div>

        <%-- <table id="dg" title="用户列表" class="easyui-datagrid" style="width:700px;height:350px"
            url="UserList.aspx/LoadData"
            toolbar="#toolbar" pagination="true"
            rownumbers="true" fitColumns="true" singleSelect="true">
        <thead>
            <tr>
              <th field="Id" width="50">Id</th>
              <th field="Account" width="50">用户名</th>
              <th field="Name" width="50">姓名</th>
               
               
            </tr>
        </thead>
    </table>
    <div id="toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">New User</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">Edit User</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">Remove User</a>
    </div>
    
    <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
            closed="true" buttons="#dlg-buttons">
        <div class="ftitle">用户信息</div>
        <form id="fm" method="post" novalidate>
            <div class="fitem">
                <label>First Name:</label>
                <input name="firstname" class="easyui-validatebox" required="true">
            </div>
            <div class="fitem">
                <label>Last Name:</label>
                <input name="lastname" class="easyui-validatebox" required="true">
            </div>
            <div class="fitem">
                <label>Phone:</label>
                <input name="phone">
            </div>
            <div class="fitem">
                <label>Email:</label>
                <input name="email" class="easyui-validatebox" validType="email">
            </div>
        </form>
    </div>
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">返回</a>
    </div>
   --%>
    </form>
     <script type="text/javascript">
         var url;
         function newUser() {
             $('#dlg').dialog('open').dialog('setTitle', '添加用户');
             $('#fm').form('clear');
             url = 'save_user.php';
         }
         function editUser() {
             var row = $('#dg').datagrid('getSelected');
             if (row) {
                 $('#dlg').dialog('open').dialog('setTitle', '编辑用户');
                 $('#fm').form('load', row);
                 url = 'update_user.php?id=' + row.id;
             }
         }
         function saveUser() {
             $('#fm').form('submit', {
                 url: url,
                 onSubmit: function () {
                     return $(this).form('validate');
                 },
                 success: function (result) {
                     var result = eval('(' + result + ')');
                     if (result.errorMsg) {
                         $.messager.show({
                             title: 'Error',
                             msg: result.errorMsg
                         });
                     } else {
                         $('#dlg').dialog('close');        // close the dialog
                         $('#dg').datagrid('reload');    // reload the user data
                     }
                 }
             });
         }
         function destroyUser() {
             var row = $('#dg').datagrid('getSelected');
             if (row) {
                 $.messager.confirm('消息', '您确定删除该用户吗?', function (r) {
                     if (r) {
                         $.post('destroy_user.php', { id: row.id }, function (result) {
                             if (result.success) {
                                 $('#dg').datagrid('reload');    // reload the user data
                             } else {
                                 $.messager.show({    // show error message
                                     title: 'Error',
                                     msg: result.errorMsg
                                 });
                             }
                         }, 'json');
                     }
                 });
             }
         }
    </script>
  
</body>
</html>
